package responsitory;

import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import bean.JiaoYiJiLuBean;
import bean.LuntanForumItemBean;
import bean.measge_bean.WeiXiuiJiLuBean;
import bean.messge_bean.MesgeBeans;
import bean.messge_bean.SystemMessgeBean;
import bean.order_bean.RepairBean;
import bean.order_bean.WeixiuKeJieBen;
import bean.personal_bean.AccountBean;
import bean.personal_bean.PayMoneyBean;
import bean.personal_bean.ZhiFuBaoBandingTypebean;
import interfaces.ISysMesgenance;
import util.volley.BaseErrorListener;
import util.volley.BaseNetRepository;
import util.volley.BaseSuccessReqListener;
import util.volley.ByJsonRequest;
import util.volley.ICompleteListener;

/**
 * Created by itboye on 2016/12/10.
 */

public class SYstemMessgepomsitory extends BaseNetRepository implements ISysMesgenance<MesgeBeans> {

    public static final  String Messge="By_Message_query";
    public static final String  API="100";
    public static final  String GetJiNeng="By_Worker_skill";
    public static final  String WeiXiuKejiedan="By_Repair_query";//维修可接单
    public static final  String MeetOrder="By_Repair_take";//接单
    public static final  String Repair="By_Repair_current";//接单By_Repair_setPrice

    public static final  String SetPrice="By_Repair_setPrice";//报价

    public static final  String Wallet="By_Wallet_setSecret";//设置初始支付密码

    public static final  String Account="By_Wallet_detail";//账户余额

    public static  final  String WeiXiuJiLu="By_Repair_queryList";//维修记录

    public static  final  String ZhanghaoList="By_Wallet_bindList";//支持账号账号列表

    public static  final  String ChongZhi="By_Wallet_order";//开始充值
    public static  final  String BandingType="By_Wallet_bindType";//支持账号类型

    public static final String SystemMeesge = "By_Message_query";//道路救援

    public static final String Bhang = "By_Wallet_bind";//道路救援

    public static final String Tixian = "By_Wallet_apply";//道路救援

    public static final String Wancheng = "By_Repair_done";//道路救援


    public static final String Secrets = "By_Wallet_checkSecret";//道路救援

    public  static  final  String deleteZhangHao="By_Wallet_bindDel";//删除绑定的账号
    public static final String dingdan = "By_Wallet_his";//余额变动记录   我的订单
    public static final String APIs="101";

    public  SYstemMessgepomsitory(ICompleteListener ICompleteListener){
        super(ICompleteListener);

    }

    @Override
    public void onSysmTemMeesge(String uid, String msgType, String pageIndex, String pageSize) {
        Type type = new TypeToken<MesgeBeans>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type","6042");
        map.put("page_index",pageIndex);
        map.put("page_size",pageSize);

        (new ByJsonRequest.Builder<MesgeBeans>())
                .setTypeVerParamsAndReturnClass(Messge, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<MesgeBeans>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSysmTemMeesgeRes(String uid, String msgType, String pageIndex, String pageSize) {
        Type type = new TypeToken<SystemMessgeBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type",msgType);
        map.put("page_index",pageIndex);
        map.put("page_size",pageSize);

        (new ByJsonRequest.Builder<SystemMessgeBean>())
                .setTypeVerParamsAndReturnClass(Messge, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<SystemMessgeBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onGetJineng(String uid) {
        Type type = new TypeToken<LuntanForumItemBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);


        (new ByJsonRequest.Builder<LuntanForumItemBean>())
                .setTypeVerParamsAndReturnClass(GetJiNeng, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<LuntanForumItemBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onWeixiuJie(String uid, String current_page, String per_page, String lng, String lat,String order) {
        Type type = new TypeToken<WeixiuKeJieBen>() {
        }.getType();
        String apiVer = APIs;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("current_page",current_page);
        map.put("per_page", per_page);
        map.put("lng",lng);
        map.put("lat",lat);
        map.put("order",order);
        map.put("km","50");
        (new ByJsonRequest.Builder<WeixiuKeJieBen>())
                .setTypeVerParamsAndReturnClass(WeiXiuKejiedan, "102", map, type)
                .requestListener(
                        new BaseSuccessReqListener<WeixiuKeJieBen>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onMeetOrder(String uid, String id) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id",id);


        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(MeetOrder, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onRepair(String uid, String group_id) {
        Type type = new TypeToken<RepairBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("group_id",group_id);


        (new ByJsonRequest.Builder<RepairBean>())
                .setTypeVerParamsAndReturnClass(Repair, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<RepairBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onsetPrice(String uid, String id, double repair_price, double stuff_price) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id",id);
        map.put("repair_price", repair_price);
        map.put("stuff_price",stuff_price);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(SetPrice, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSttringPayPwd(String uid, String news) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("new",news);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Wallet, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onChongzhiPwd(String uid, String old, String news) {
        Type type = new TypeToken<String>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("old", old);
        map.put("new", news);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Wallet, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();

    }

    @Override
    public void onAccount(String uid) {
        Type type = new TypeToken<AccountBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        (new ByJsonRequest.Builder<AccountBean>())
                .setTypeVerParamsAndReturnClass(Account, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<AccountBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onWeiXiuJiLu(String uid, String id,String repair_status, String current_page, String per_page) {
        Type Type = new TypeToken<WeiXiuiJiLuBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("group_id", id);
        map.put("current_page", current_page);
        map.put("per_page", per_page);
        map.put("repair_status", repair_status);
        (new ByJsonRequest.Builder<WeiXiuiJiLuBean>())
                .setTypeVerParamsAndReturnClass(WeiXiuJiLu, "101", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<WeiXiuiJiLuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onBangDinType() {
        Type Type = new TypeToken<List<ZhiFuBaoBandingTypebean>>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();


        (new ByJsonRequest.Builder<List<ZhiFuBaoBandingTypebean>>())
                .setTypeVerParamsAndReturnClass(BandingType, "100", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<ZhiFuBaoBandingTypebean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onZhangHaoList(String uid) {

        Type Type = new TypeToken<List<ZhiFuBaoBandingTypebean>>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid",uid);

        (new ByJsonRequest.Builder<List<ZhiFuBaoBandingTypebean>>())
                .setTypeVerParamsAndReturnClass(ZhanghaoList, "100", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<ZhiFuBaoBandingTypebean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();

    }

    @Override
    public void onChongZhi(String uid, String money) {
        Type Type = new TypeToken<PayMoneyBean>() {
        }.getType();
        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid",uid);
        map.put("money",money);

        (new ByJsonRequest.Builder<PayMoneyBean>())
                .setTypeVerParamsAndReturnClass(ChongZhi, "100", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<PayMoneyBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onSysTemMessge(String uid, String msgtype, String pageindex, String pagesize) {
        Type type = new TypeToken<MesgeBeans>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type", "6180");
        map.put("page_index", pageindex);
        map.put("page_size", pagesize);

        (new ByJsonRequest.Builder<MesgeBeans>())
                .setTypeVerParamsAndReturnClass(SystemMeesge,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<MesgeBeans>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onByWalletBind(String uid, String account, String account_type,String open_bank,String real_name) {
        Type type = new TypeToken<String>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("account", account);
        map.put("account_type", account_type);
        map.put("open_bank", open_bank);
        map.put("real_name", real_name);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Bhang,"101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onTixian(String uid, String money, String account_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("money", money);
        map.put("account_id", account_id);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Tixian,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onWieXiuWancheng(String uid, String id, String group_id) {
        Type type = new TypeToken<String>() {
        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        map.put("group_id","7");

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Wancheng,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void oncheckSecret(String uid, String secret) {
        Type type = new TypeToken<String>() {
        }.getType();
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("secret",secret);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Secrets,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onZhangDan(String uid, String current_page, String per_page) {
        Type type = new TypeToken<JiaoYiJiLuBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("current_page", current_page);
        map.put("per_page", per_page);

        (new ByJsonRequest.Builder<JiaoYiJiLuBean>())
                .setTypeVerParamsAndReturnClass(dingdan,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<JiaoYiJiLuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
    /**
     * 删除绑定的账号
     * @param uid
     * @param id
     */
    @Override
    public void deleteZhangHao(String uid, String id) {
        Type type = new TypeToken<String>() {
        }.getType();
  //      String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(deleteZhangHao, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
